package org.example.ui;

import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.awt.geom.RoundRectangle2D;

public class SearchField extends JTextField {
    private ImageIcon icon;

    public SearchField() {
        Image image = new ImageIcon("data/background/search.jpg").getImage().
                getScaledInstance(40, 40, Image.SCALE_DEFAULT);
        icon = new ImageIcon(image);
        Insets insets = new Insets(0, 40, 0, 0);
        this.setMargin(insets);
        setFont(new Font("", Font.BOLD, 15));
    }

    @Override
    public void paintComponent(Graphics g) {
        Insets insets = getInsets();
        super.paintComponent(g);
        int iconWidth = icon.getIconWidth();
        int iconHeight = icon.getIconHeight();
        int Height = this.getHeight();
        icon.paintIcon(this, g, (insets.left - iconWidth)/2, (Height - iconHeight) / 2);
    }
}
